package com.panda.system.controller;

import com.panda.common.annotation.Log;
import com.panda.common.core.controller.BaseController;
import com.panda.common.core.domain.AjaxResult;
import com.panda.common.core.page.TableDataInfo;
import com.panda.common.enums.BusinessType;
import com.panda.common.utils.poi.ExcelUtil;
import com.panda.system.domain.PandaTaskMonitoring;
import com.panda.system.service.IPandaTaskMonitoringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作节点明细Controller
 * 
 * @author ruoyi
 * @date 2021-01-02
 */
@RestController
@RequestMapping("/system/monitoring")
public class PandaTaskMonitoringController extends BaseController
{
    @Autowired
    private IPandaTaskMonitoringService pandaTaskMonitoringService;

    /**
     * 查询操作节点明细列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PandaTaskMonitoring pandaTaskMonitoring)
    {
        startPage();
        List<PandaTaskMonitoring> list = pandaTaskMonitoringService.selectPandaTaskMonitoringList(pandaTaskMonitoring);
        return getDataTable(list);
    }

    /**
     * 导出操作节点明细列表
     */
    @Log(title = "操作节点明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PandaTaskMonitoring pandaTaskMonitoring)
    {
        List<PandaTaskMonitoring> list = pandaTaskMonitoringService.selectPandaTaskMonitoringList(pandaTaskMonitoring);
        ExcelUtil<PandaTaskMonitoring> util = new ExcelUtil<PandaTaskMonitoring>(PandaTaskMonitoring.class);
        return util.exportExcel(list, "monitoring");
    }

    /**
     * 获取操作节点明细详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pandaTaskMonitoringService.selectPandaTaskMonitoringById(id));
    }

    /**
     * 新增操作节点明细
     */
    @Log(title = "操作节点明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PandaTaskMonitoring pandaTaskMonitoring)
    {
        return toAjax(pandaTaskMonitoringService.insertPandaTaskMonitoring(pandaTaskMonitoring));
    }

    /**
     * 修改操作节点明细
     */
    @Log(title = "操作节点明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PandaTaskMonitoring pandaTaskMonitoring)
    {
        return toAjax(pandaTaskMonitoringService.updatePandaTaskMonitoring(pandaTaskMonitoring));
    }

    /**
     * 删除操作节点明细
     */
    @Log(title = "操作节点明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pandaTaskMonitoringService.deletePandaTaskMonitoringByIds(ids));
    }
}
